[BLKTAP] Fix SMP debugging assert failures in blktap
authorAndrew Warfield <andy@xensource.com>
Thu, 28 Sep 2006 19:03:01 +0000 (12:03 -0700)
committerAndrew Warfield <andy@xensource.com>
Thu, 28 Sep 2006 19:03:01 +0000 (12:03 -0700)
blktap is calling non-atomic kernel functions with irqs disabled, which
hits various kernel debug traps if those are enabled.  The problem is
req_increase(), which takes the pending_free_lock.

This function is currently only ever called from module initialiation,
where it is impossible for it to race against anything else.  Its
companion, req_decrease(), is not called at all.

Fix by removing the offending locking from req_increase() and, while
we're at it, remove req_decrease() entirely.

Signed-off-by: Stephen Tweedie <sct@redhat.com>
linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c

index c3ba5ac7f12cc04210ae14fdd2438e824100f50b..a5b9e56c1a088f6f41943f5f2ecb77f9081345d2 100644 (file)
@@ -694,11 +694,8 @@ static int req_increase(void)
 {
        int i, j;
        struct page *page;
-       unsigned long flags;
        int ret;
 
-       spin_lock_irqsave(&pending_free_lock, flags);
-
        ret = -EINVAL;
        if (mmap_alloc >= MAX_PENDING_REQS || mmap_lock) 
                goto done;
@@ -763,8 +760,7 @@ static int req_increase(void)
 
        mmap_alloc++;
        DPRINTK("# MMAPs increased to %d\n",mmap_alloc);
- done:
-       spin_unlock_irqrestore(&pending_free_lock, flags);
+done:
        return ret;
 }
 
@@ -794,37 +790,6 @@ static void mmap_req_del(int mmap)
        mmap_alloc--;
 }
 
-/*N.B. Currently unused - will be accessed via sysfs*/
-static void req_decrease(void)
-{
-       pending_req_t *req;
-       int i;
-       unsigned long flags;
-
-       spin_lock_irqsave(&pending_free_lock, flags);
-
-       DPRINTK("Req decrease called.\n");
-       if (mmap_lock || mmap_alloc == 1) 
-               goto done;
-
-       mmap_lock = 1;
-       mmap_inuse = MAX_PENDING_REQS;
-       
-        /*Go through reqs and remove any that aren't in use*/
-       for (i = 0; i < MAX_PENDING_REQS ; i++) {
-               req = &pending_reqs[mmap_alloc-1][i];
-               if (req->inuse == 0) {
-                       list_del(&req->free_list);
-                       mmap_inuse--;
-               }
-       }
-       if (mmap_inuse == 0)
-               mmap_req_del(mmap_alloc-1);
- done:
-       spin_unlock_irqrestore(&pending_free_lock, flags);
-       return;
-}
-
 static pending_req_t* alloc_req(void)
 {
        pending_req_t *req = NULL;